exports.login = function (req, res) {

    var bodyParams = req.routeInfo.bodyParams;

    //最终结果
    var resultData = {};

    //任务流创建
    async.waterfall([

            //验证帐号密码
            function (cb) {

                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.search_user_info + "/u_username/" + bodyParams.username,
                        method: 'POST',
                        data: {
                            fields: ["u_id", "u_username", "u_password", "u_nickname", "u_header_url", "openid"].join(",")
                        }
                    },
                    function (err, data) {
                        //console.log(data);
                        //判断是否有错误信息
                        if (err) {
                            return cb(err, data);
                        }

                        //判断用户是否存在
                        if (data.data.length <= 0) {
                            return RES.response(res, false, "抱歉，该用户不存在");
                        }

                        var userInfo = data.data[0];

                        //判断用户密码是否正确
                        if (common.md5(bodyParams.password) != userInfo.u_password) {
                            return RES.response(res, false, "抱歉，密码输入错误");
                        }


                        //返回登录成功后的数据
                        resultData.userid = userInfo.u_id;
                        resultData.username = userInfo.u_username;
                        resultData.nickname = userInfo.u_nickname;
                        resultData.openid = userInfo.openid;

                        cb();


                    }
                );

            },

        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}